package edu.scsu.csci;

import java.lang.annotation.Annotation;

import edu.scsu.csci.validator.ValidationException;


/**
 * <p> Interface to be implemented by all the validators defined for the application. </P>
 * 
 * <p> A validator is responsible for validating the domain object fields against
 * 	   the HTTP request parameters passed based on the vaildation rules defined on 
 * 	   these fields with the help of validator annotations.
 * </p>
 * 	  
 * <p> A user defined validator should also be defined in the webconfig file as
 * 	   <code>
 * 			<validator>
 *   			<type>java.lang.String</type>
 *  			<validatorClass>edu.scsu.csci.validator.StringValidator</validatorClass>
 *  			<annotationClass>edu.scsu.csci.annotation.validator.AIntegerValidator</annotationClass>
 *          </validator>
 *	   </code>
 *	   <b>or</b> can also be configured directly by
 *	   <code> 
 *			ValidatorAnnotationRegistory.getInstance().register(this.annotaionClazz, ReflectionUtil.instantiate(this.validatorClazz))
 *		</code>
 * </p>
 *
 * <p>	The prefered way to register a validator is to do it through the configuration
 *		file as this promotes more loose coupling with the framework. </p>
 *
 * @author Maqbool Khan
 * @since jdk 1.5
 * @see	edu.scsu.csci.annotation.validator.ACharValidator
 * @see	edu.scsu.csci.annotation.validator.ADateValidator
 * @see	edu.scsu.csci.annotation.validator.ADoubleValidator
 * @see	edu.scsu.csci.annotation.validator.AFloatValidator
 * @see	edu.scsu.csci.annotation.validator.AIntegerValidator
 * @see	edu.scsu.csci.annotation.validator.ANullValidator
 * @see	edu.scsu.csci.annotation.validator.AShortValidator
 * @see	edu.scsu.csci.annotation.validator.AStringValidator
 * @see	edu.scsu.csci.annotation.validator.AValidate
 * @see edu.scsu.csci.validator.ValidationException
 * @viz.diagram IValidator.tpx
 * 
 */
public interface IValidator<T extends Annotation, G> {
	
	/**
	 * Returns true is the given validator can validate the domain objects of type <code> type </code>
	 * else returns false.
	 * 
	 * @param type
	 * @return
	 */
	//public boolean canValidate(T annotation, G object);
	
	/**
	 * Validates the passed domain object according to the annotation.
	 * 
	 * Returns true if the validation succeeds else returns false.
	 * 
	 * @param annotation
	 * @param object
	 */
	public void	validate(T annotation, G object) throws ValidationException ;
	
}
